﻿
namespace Project.Co_DataTransformationPrototype
{

    partial class EntityAttribute
    {
        private Entity parentEntity;

        protected override void OnDeleting()
        {
            // Ensure availability of the parent entity for the deleted attribute
            if (this.Entity != null)
                parentEntity = this.Entity;
            else if (this.CurrentEntityID != null)
                parentEntity = this.Store.ElementDirectory.FindElement(this.CurrentEntityID) as Entity;

            base.OnDeleting();
        }

        /// <summary>
        /// Gets the entity object which contained the deleted entity attribute
        /// </summary>
        public Entity ParentEntity
        {
            get { return parentEntity; }
        }
    }

}
